Add macOS built-in color picker capability #84
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
osascript
is the built-in automation program in macOS.The method of triggering the macOS color picker from
osascript
is documented here:https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/PromptforaColor.html#//apple_ref/doc/uid/TP40016239-CH86-SW1
There is a weirdness of
osascript
in thatconsole.log
only writes tostderr
regardless of the documented "write to stdout" flag. A workaround was found here and linked in the relevant comment: https://apple.stackexchange.com/a/278395The picker is only attempted when
#[cfg(target_os = "macos")]
, however it's still listed in the "Supported tools" help text becauseclap
make it somewhat hard to customize that help text (e.g. generating from the list of tools) because it does not take ownership of strings. Related: clap-rs/clap#1041